home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / pas_0593.zip / FFEXIST.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-30  |  1KB  |  37 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 193 of 292
  3. From : Wilbert van Leijen                  2:281/256.14         14 May 93  19:29
  4. To   : Vince Laurent                       1:382/10.0
  5. Subj : a few questions...
  6. ────────────────────────────────────────────────────────────────────────────────
  7. 07 May 93, Vince Laurent writes to All:
  8.  
  9.  VL> 1. What is the quickest way to check for the existance of a file?
  10.  VL>    I am going to be running the application on a network and would
  11.  VL>    like to minimize network traffic.
  12.  
  13. You cannot bypass the file server for this purpose, the reason should be
  14. obvious.  So peer-to-peer communication protocols are out.
  15.  
  16. Suggestion: obtain the file's attributes using INT 21h, AH=43h, DS:DX -> ASCIIZ
  17. filename.
  18. If this call sets the carry flag, the file doesn't exist.  Otherwise, it does.
  19. Advantage: no need for an attempt to open it.}
  20.  
  21. Function FileExist(filename : String) : Boolean; Assembler;
  22.  
  23. ASM
  24.         PUSH   DS
  25.         LDS    SI, [filename]      { make ASCIIZ }
  26.         XOR    AH, AH
  27.         LODSB
  28.         XCHG   AX, BX
  29.         MOV    Byte Ptr [SI+BX], 0
  30.         MOV    DX, SI
  31.         MOV    AX, 4300h           { get file attributes }
  32.         INT    21h
  33.         MOV    AL, False
  34.         JC     @1                  { fail? }
  35.         INC    AX
  36. @1:     POP    DS
  37. end;  { FileExist }